package net.zhiji.gldraw;

import android.app.NativeActivity;
import android.os.Bundle;
import android.view.View;
import net.zhiji.LogSaver;

public class Main extends NativeActivity {

    private boolean debug_mode = true;  // 改这里

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        if (debug_mode == true) {
            LogSaver.startLogging(this);
        }
        super.onCreate(savedInstanceState);
        int SDK_INT = android.os.Build.VERSION.SDK_INT;
        if (SDK_INT >= 19) {
            setImmersiveSticky();
            View decorView = getWindow().getDecorView();
            decorView.setOnSystemUiVisibilityChangeListener
            (new View.OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        setImmersiveSticky();
                    }
                });
        }
    }
    
    // 设置全屏
    public void setImmersiveSticky() {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
                                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }

    // private native void zj_input_text_android(String text);

    /*@Override
     public boolean dispatchKeyEvent(KeyEvent event) {
     String str = event.getCharacters();
     if ((str == null) && (event.getAction() == KeyEvent.ACTION_UP)) {
     int ascii_code = event.getUnicodeChar(event.getMetaState());
     str = "" + (char)ascii_code;
     }
     String info = "text:" + str + "\nKeyCode:" + event.getKeyCode() + "\n";
     Toast.makeText(this, info, Toast.LENGTH_SHORT).show();
     if (str != null) {
     // zj_input_text_android(str);
     } else {
     Log.e("dispatchKeyEvent", "can't get input text.");
     }
     return super.dispatchKeyEvent(event);
     }

     public void showSoftInput() {
     InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
     imm.showSoftInput(this.getWindow().getDecorView(), 0);
     }

     public void hideSoftInput() {
     InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
     imm.hideSoftInputFromWindow(this.getWindow().getDecorView().getWindowToken(), 0);
     }*/
}
